<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/view/common/tag.jsp" %>
<html>
<head>
    <title>聊天机器人展览用户中心</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${baseurl}/lib/layui/css/layui.css">
    <link rel="stylesheet" href="${baseurl}/css/portal/global.css">
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>

<div class="layui-container fly-marginTop fly-user-main">
    <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
        <li class="layui-nav-item">
            <a href="${baseurl}/user/personalCenter">
                <i class="layui-icon">&#xe612;</i>
                用户中心
            </a>
        </li>
        <li class="layui-nav-item layui-this">
            <a href="${baseurl}/user/leaveMessage">
                <i class="layui-icon">&#xe620;</i>
                给管理员留言
            </a>
        </li>
    </ul>

    <div class="fly-panel fly-panel-user" pad20>
        <div class="layui-form layui-form-pane">
            <div class="layui-tab layui-tab-brief" lay-filter="user">
                <ul class="layui-tab-title">
                    <li class="layui-this">给管理员留言<!-- 编辑帖子 --></li>
                </ul>

                <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form" action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">艺术展览</label>
                                <div class="layui-input-block">
                                    <input type="hidden" name="exhibitionName" id="exhibitionName">
                                    <select name="exhibitionId" id="galleryNameSelect" lay-filter="galleryNameSelect">
                                        <option>请选择艺术展</option>
                                    </select>
                                </div>
                            </div>

                            <div class="layui-form-item layui-form-text">
                                <div class="layui-input-block">
                                    <textarea id="L_content" name="commentContent" lay-verify="commentContent" placeholder="详细描述" class="layui-textarea fly-editor" style="height: 260px;"></textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <button class="layui-btn" lay-filter="publish" lay-submit>立即发布</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div class="fly-footer">
    <p>FUN 2021 &copy; FUN.com 出品</p>
</div>
<script type="text/javascript" src="${baseurl}/lib/layui/layui.js"></script>
<script type="text/javascript" src="${baseurl}/lib/layui_custom/Hlayui.js"></script>

<script>
    layui.use(['layer', 'laytpl', 'form','laypage','element','layedit','layerCustom'], function () {
        var $ =layui.jquery;
        var layer = layui.layer;
        var laytpl = layui.laytpl;
        var form = layui.form;
        var layerCustom = layui.layerCustom;
        var element = layui.element;
        var laypage = layui.laypage;
        var layedit = layui.layedit;
        // initSelect();

        $(function() {
            var url =BaseUrl + "exhibitionInfo/list";
            var param = {
                page:1,
                limit:9999
            }
            $.ajax({
                url: url,
                type: "get",
                async: false,
                data: param,
                dataType: "json",
                success: function (result) {
                    for (var i=0;i < result.data.length;i++) {
                        var item = result.data[i];
                        $("#galleryNameSelect").append("<option  value=" + item.id + ">" + item.exhibitionName + "</option>");
                    }
                    //必须要重新渲染一下 不然会失效
                    form.render('select');
                }
            });
        });


        var editIndex = layedit.build('L_content',{
            uploadImage: {url: BaseUrl +'/file/uploadImage', type: 'post'}
        });


        //自定义验证规则
        form.verify({
            commentContent: function(value) {
                layedit.sync(editIndex);
            }
        });


        form.on('select(galleryNameSelect)',function (data) {
            var text = data.elem[data.elem.selectedIndex].text;
            $("#exhibitionName").val(text);
        });

        form.on('submit(publish)', function (data) {
            layedit.sync(editIndex);
            var url = BaseUrl +"exhibitionComment/save";
            $.post(url,data.field,function (result) {
                if (result.success) {
                    layerCustom.greenLaughMsg(result.msg,function () {
                        window.location.reload();
                    })
                }
            },"json");
            return false;
        })
    })
</script>
</body>
</html>
